package com.wfs.staticfield;

/**
 * static修饰成员变量
 * 学习静态变量与实例变量
 */
public class Test {
    public static void main(String[] args) {
        Student s1 = new Student();
        Student s2 = new Student();
        s2.age = 19;
        s1.age = 18;
        // 1通过类名访问静态变量
        Student.name = "张三";
        System.out.println(s1.age);
        System.out.println(Student.name);
        // 2通过对象名访问静态变量（不推荐）
        s2.name = "李四";
        System.out.println(s1.name);
        System.out.println(s2.name);
    }
}
